using System;
using System.Collections.Generic;
using System.Globalization;

namespace needle.Services.astra.Common
{
	/// <summary>
	/// Helper class for working with <see cref="CultureInfo"/>s.
	/// </summary>
	public static class CultureInfoHelper
	{
		/// <summary>
		/// Gets list of <see cref="CultureInfo"/>s.
		/// </summary>
		/// <param name="cultureTypes">Required culture types.</param>
		/// <param name="asReadOnly">Whether returned list should be readonly.</param>
		/// <returns>New list.</returns>
		public static IList<CultureInfo> GetSortedCultures(CultureTypes cultureTypes, bool asReadOnly)
		{
			List<CultureInfo> cultures = new List<CultureInfo>(CultureInfo.GetCultures(cultureTypes));
			cultures.Sort(delegate(CultureInfo item1, CultureInfo item2)
				{ return item1.DisplayName.CompareTo(item2.DisplayName); });
			if (asReadOnly)
				return cultures.AsReadOnly();
			else
				return cultures;
		}
	}
}
